# coding: utf-8
from sqlalchemy import CHAR, Column, JSON, String, TIMESTAMP, Table, Text, text, MetaData
from sqlalchemy.dialects.mysql import ENUM, INTEGER, LONGTEXT, MEDIUMINT, MEDIUMTEXT, TEXT, TINYINT, VARCHAR
from ..database import db,serialize

class User(db.Model):
    __tablename__ = 'users'

    id = Column(INTEGER(10), primary_key=True)
    gid = Column(INTEGER(11), nullable=False, server_default=text("'1'"), comment='组ID')
    openid = Column(CHAR(255, 'utf8mb4_unicode_ci'), index=True)
    username = Column(String(30, 'utf8mb4_unicode_ci'), comment='用户名')
    password = Column(VARCHAR(200), comment='密码')
    token = Column(String(255, 'utf8mb4_unicode_ci'), comment='API登陆用')
    phone = Column(String(20, 'utf8mb4_unicode_ci'), comment='手机号')
    nickname = Column(String(30, 'utf8mb4_unicode_ci'), comment='昵称')
    thumb = Column(String(255, 'utf8mb4_unicode_ci'), comment='头像')
    email = Column(String(100, 'utf8mb4_unicode_ci'), comment='邮箱')
    sex = Column(TINYINT(4), nullable=False, server_default=text("'0'"), comment='性别')
    birthday = Column(String(25, 'utf8mb4_unicode_ci'), comment='生日')
    address = Column(String(200, 'utf8mb4_unicode_ci'), comment='地址')
    status = Column(TINYINT(4), nullable=False, server_default=text("'1'"), comment='状态，1正常0禁用')
    created_at = Column(TIMESTAMP)
    updated_at = Column(TIMESTAMP)

